package com.jwsoft.manager.core.gateway.controller;

import com.bifang.assistant.common.constants.Validators;
import com.bifang.assistant.common.vo.BaseVO;
import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.engine.protect.core.annotation.Idempotent;
import com.github.pagehelper.PageInfo;
import com.jwsoft.manager.common.vo.eduBreakThrough.EduBreakThroughKeyVO;
import com.jwsoft.manager.common.vo.eduBreakThrough.EduBreakThroughQueryVO;
import com.jwsoft.manager.common.vo.eduBreakThrough.EduBreakThroughVO;
import com.jwsoft.manager.common.vo.eduBreakThroughDetail.EduBreakThroughDetailKeyVO;
import com.jwsoft.manager.common.vo.eduBreakThroughDetail.EduBreakThroughDetailQueryVO;
import com.jwsoft.manager.common.vo.eduBreakThroughDetail.EduBreakThroughDetailVO;
import com.jwsoft.manager.core.integration.EduBreakThroughIntegration;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 突破学区管理网关
 *
 * @author chenzh
 * @since 2023-06-08
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "突破学区管理", description = "突破学区管理")
public class EduBreakThroughController {

    @Autowired
    public EduBreakThroughIntegration eduBreakThroughIntegration;

    @Operation(summary = "突破学区管理分页查询", description = "突破学区管理分页查询")
    @PostMapping(value = "/eduBreakThrough0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduBreakThroughVO>> getList(@RequestBody @Validated EduBreakThroughQueryVO vo) {
        return AppResponse.successData(eduBreakThroughIntegration.getList(vo));
    }

    @Operation(summary = "突破学区管理根据主键查询详情", description = "突破学区管理根据主键查询详情")
    @PostMapping(value = "/eduBreakThrough0002", produces = "application/json;charset=UTF-8")
    public AppResponse<EduBreakThroughVO> getById(@RequestBody @Validated EduBreakThroughKeyVO vo) {
        return AppResponse.successData(eduBreakThroughIntegration.getById(vo));
    }

    @Idempotent(expire = "PT2S") //2秒内防重复提交
    @Operation(summary = "突破学区管理新增", description = "突破学区管理新增")
    @PostMapping(value = "/eduBreakThrough0004", produces = "application/json;charset=UTF-8")
    public AppResponse<EduBreakThroughVO> add(@RequestBody @Validated(value = {Validators.Add.class}) EduBreakThroughVO vo) {
        return AppResponse.successData(eduBreakThroughIntegration.add(vo));
    }

    @Idempotent(expire = "PT2S") //2秒内防重复提交
    @Operation(summary = "突破学区管理修改", description = "突破学区管理修改")
    @PostMapping(value = "/eduBreakThrough0005", produces = "application/json;charset=UTF-8")
    public AppResponse<EduBreakThroughVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) EduBreakThroughVO vo) {
        return AppResponse.successData(eduBreakThroughIntegration.edit(vo));
    }

    @Idempotent(expire = "PT2S") //2秒内防重复提交
    @Operation(summary = "突破学区管理删除", description = "突破学区管理删除")
    @PostMapping(value = "/eduBreakThrough0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduBreakThroughKeyVO vo) {
        eduBreakThroughIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }

    @Operation(summary = "突破学区关联学校查询", description = "突破学区关联学校查询")
    @PostMapping(value = "/eduBreakThrough0007", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduBreakThroughDetailVO>> getBreakSchoolQuery(@RequestBody @Validated EduBreakThroughDetailQueryVO vo) {
        return AppResponse.successData(eduBreakThroughIntegration.getBreakSchoolQuery(vo));
    }

    @Idempotent(expire = "PT2S") //2秒内防重复提交
    @Operation(summary = "突破学区关联学校删除", description = "突破学区关联学校删除")
    @PostMapping(value = "/eduBreakThrough0008", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduBreakThroughDetailKeyVO vo) {
        eduBreakThroughIntegration.delDetail(vo);
        return AppResponse.successMsg("删除成功！");
    }

    @Idempotent(expire = "PT2S") //2秒内防重复提交
    @Operation(summary = "突破学区管理单个新增关联学校信息", description = "突破学区管理单个新增关联学校信息")
    @PostMapping(value = "/eduBreakThrough0009", produces = "application/json;charset=UTF-8")
    public AppResponse<EduBreakThroughDetailVO> addDetail(@RequestBody @Validated(value = {Validators.Add.class}) EduBreakThroughDetailVO vo) {
        return AppResponse.successData(eduBreakThroughIntegration.addDetail(vo));
    }
    @Idempotent(expire = "PT2S") //2秒内防重复提交
    @Operation(summary = "突破学区管理复制上年数据", description = "突破学区管理复制上年数据")
    @PostMapping(value = "/eduBreakThrough0010", produces = "application/json;charset=UTF-8")
    public AppResponse init(@RequestBody BaseVO vo) {
        eduBreakThroughIntegration.init(vo);
        return AppResponse.successMsg("初始化成功");
    }
}
